
const cloud = require('wx-server-sdk');  
   
cloud.init();   
const db = cloud.database();  
  
// 云函数入口函数  
exports.main = async (event, context) => {  
  const { roomId } = event;  
  try {  
    // 查询 rooms 集合中的所有记录  
    const result = await db.collection('rooms').where({  
      roomId: roomId,  
    }).get();  
  
    // 返回查询结果  
    return {  
      success: true,  
      data: result.data, // result.data 是包含所有记录的数组  
    };  
  } catch (error) {    
    console.error('Error querying rooms collection:', error);  
    return {  
      success: false,  
      error: error.message,  
    };  
  }  
};